<template>
  <div class="mv-and-video">
    <MvItem v-for="item in total" :key="item.id" :item="item" />
  </div>
</template>

<script>
import MvItem from "@/components/basics/MvItem.vue";
export default {
  components: {
    MvItem,
  },
  async created() {
    // 全部 = 歌手视频 + 歌手mv
    // 歌手视频
    const { id } = this.$route.query;
    const { getArtistMv, getArtistVideo } = this;
    const response = await Promise.all([getArtistMv(id), getArtistVideo(id)]);

    this.mvs = response[0].data.mvs;
    this.records = response[1].data.data.records;

    this.total = this.mvs.concat(this.records);
  },
  data() {
    return {
      records: [],
      mvs: [],
      total: [],
    };
  },

  methods: {
    /**
     * 获取歌手视频
     * @param id 歌手id
     */
    async getArtistVideo(id) {
      return await this.axios.get(`/artist/video?id=${id}`);
    },

    /**
     * 获取歌手 mv
     * @param id 歌手id
     */
    async getArtistMv(id) {
      return await this.axios.get(`/artist/mv?id=${id}`);
    },
  },
};
</script>

<style scoped>
.mv-and-video {
  padding: 10px;
}
</style>
